<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <ul id="message">
    <li>聊天:</li>
  </ul>
  <input type="text" placeholder="发送消息" id="send">

  <script>
    send.onkeydown = event => {
      if (event.keyCode === 13) {
        // .replace(/</g, '&lt;').replace(/>/g, '&gt;')
        message.innerHTML += `<li>${event.target.value}</li>`
        event.target.value = ''
      }
    }
  </script>
</body>
</html>